/********

Project - College affirmative action bans and health risk behaviors

Dataset - TUS-CPS

Version - May 29, 2019 (for replication archive)

Description - This file contains the code we used to create the majority of our cleaned TUS-CPS dataset (TUSCPS_datafile.dta). 
The first part (Part 1) of code below calls for original source data from IPUMS-CPS (see https://cps.ipums.org/cps/)

The second part of the code cleans the data to define the exposure and create relevant race/ethnicity groups
Here, we also adds in state-year covariates (file used to do so are not provided with these materials as they are entirely
available in the final data file).

********/

*CPS FILEPATHS
global data "[YOUR FILE PATH]"

*********************************
**PART 1 - READ IN IPUMS CPS DATA
*********************************

set more off

clear
quietly infix                 ///
  int     year       1-4      ///
  long    serial     5-9      ///
  byte    month      10-11    ///
  double  hwtfinl    12-21    ///
  double  cpsid      22-35    ///
  byte    statefip   36-37    ///
  long    county     38-42    ///
  int     faminc     43-45    ///
  byte    pernum     46-47    ///
  double  wtfinl     48-61    ///
  double  cpsidp     62-75    ///
  byte    age        76-77    ///
  byte    sex        78-78    ///
  int     race       79-81    ///
  byte    ftype      82-82    ///
  byte    famrel     83-83    ///
  int     hispan     84-86    ///
  int     educ       87-89    ///
  byte    schlcoll   90-90    ///
  byte    tcig100    91-92    ///
  byte    tfreq      93-94    ///
  int     tagesmk    95-97    ///
  int     tcigday    98-100   ///
  byte    tcigmonth  101-102  ///
  int     educ_head  103-105  ///
  int     educ_mom   106-108  ///
  int     educ_mom2  109-111  ///
  int     educ_pop   112-114  ///
  int     educ_pop2  115-117  ///
  using "$data/cps_tus_source.dat"

replace hwtfinl   = hwtfinl   / 10000
replace wtfinl    = wtfinl    / 10000

format hwtfinl   %10.4f
format cpsid     %14.0f
format wtfinl    %14.4f
format cpsidp    %14.0f

label var year      `"Survey year"'
label var serial    `"Household serial number"'
label var month     `"Month"'
label var hwtfinl   `"Household weight, Basic Monthly"'
label var cpsid     `"CPSID, household record"'
label var statefip  `"State (FIPS code)"'
label var county    `"FIPS county code"'
label var faminc    `"Family income of householder"'
label var pernum    `"Person number in sample unit"'
label var wtfinl    `"Final Basic Weight"'
label var cpsidp    `"CPSID, person record"'
label var age       `"Age"'
label var sex       `"Sex"'
label var race      `"Race"'
label var ftype     `"Family Type"'
label var famrel    `"Relationship to family"'
label var hispan    `"Hispanic origin"'
label var educ      `"Educational attainment recode"'
label var schlcoll  `"School or college attendance"'
label var tcig100   `"Smoked 100 or more cigarettes in entire life"'
label var tfreq     `"Current frequency of cigarette smoking"'
label var tagesmk   `"Age when started smoking cigarettes regularly"'
label var tcigday   `"Average number of cigarettes currently smoked daily"'
label var tcigmonth `"Number of days smoked on in past 30 days"'
label var educ_head `"Educational attainment recode [of head]"'
label var educ_mom  `"Educational attainment recode [of mother]"'
label var educ_mom2 `"Educational attainment recode [of same sex mother]"'
label var educ_pop  `"Educational attainment recode [of father]"'
label var educ_pop2 `"Educational attainment recode [of same sex father]"'

label define month_lbl 01 `"January"'
label define month_lbl 02 `"February"', add
label define month_lbl 03 `"March"', add
label define month_lbl 04 `"April"', add
label define month_lbl 05 `"May"', add
label define month_lbl 06 `"June"', add
label define month_lbl 07 `"July"', add
label define month_lbl 08 `"August"', add
label define month_lbl 09 `"September"', add
label define month_lbl 10 `"October"', add
label define month_lbl 11 `"November"', add
label define month_lbl 12 `"December"', add
label values month month_lbl

label define statefip_lbl 01 `"Alabama"'
label define statefip_lbl 02 `"Alaska"', add
label define statefip_lbl 04 `"Arizona"', add
label define statefip_lbl 05 `"Arkansas"', add
label define statefip_lbl 06 `"California"', add
label define statefip_lbl 08 `"Colorado"', add
label define statefip_lbl 09 `"Connecticut"', add
label define statefip_lbl 10 `"Delaware"', add
label define statefip_lbl 11 `"District of Columbia"', add
label define statefip_lbl 12 `"Florida"', add
label define statefip_lbl 13 `"Georgia"', add
label define statefip_lbl 15 `"Hawaii"', add
label define statefip_lbl 16 `"Idaho"', add
label define statefip_lbl 17 `"Illinois"', add
label define statefip_lbl 18 `"Indiana"', add
label define statefip_lbl 19 `"Iowa"', add
label define statefip_lbl 20 `"Kansas"', add
label define statefip_lbl 21 `"Kentucky"', add
label define statefip_lbl 22 `"Louisiana"', add
label define statefip_lbl 23 `"Maine"', add
label define statefip_lbl 24 `"Maryland"', add
label define statefip_lbl 25 `"Massachusetts"', add
label define statefip_lbl 26 `"Michigan"', add
label define statefip_lbl 27 `"Minnesota"', add
label define statefip_lbl 28 `"Mississippi"', add
label define statefip_lbl 29 `"Missouri"', add
label define statefip_lbl 30 `"Montana"', add
label define statefip_lbl 31 `"Nebraska"', add
label define statefip_lbl 32 `"Nevada"', add
label define statefip_lbl 33 `"New Hampshire"', add
label define statefip_lbl 34 `"New Jersey"', add
label define statefip_lbl 35 `"New Mexico"', add
label define statefip_lbl 36 `"New York"', add
label define statefip_lbl 37 `"North Carolina"', add
label define statefip_lbl 38 `"North Dakota"', add
label define statefip_lbl 39 `"Ohio"', add
label define statefip_lbl 40 `"Oklahoma"', add
label define statefip_lbl 41 `"Oregon"', add
label define statefip_lbl 42 `"Pennsylvania"', add
label define statefip_lbl 44 `"Rhode Island"', add
label define statefip_lbl 45 `"South Carolina"', add
label define statefip_lbl 46 `"South Dakota"', add
label define statefip_lbl 47 `"Tennessee"', add
label define statefip_lbl 48 `"Texas"', add
label define statefip_lbl 49 `"Utah"', add
label define statefip_lbl 50 `"Vermont"', add
label define statefip_lbl 51 `"Virginia"', add
label define statefip_lbl 53 `"Washington"', add
label define statefip_lbl 54 `"West Virginia"', add
label define statefip_lbl 55 `"Wisconsin"', add
label define statefip_lbl 56 `"Wyoming"', add
label define statefip_lbl 61 `"Maine-New Hampshire-Vermont"', add
label define statefip_lbl 65 `"Montana-Idaho-Wyoming"', add
label define statefip_lbl 68 `"Alaska-Hawaii"', add
label define statefip_lbl 69 `"Nebraska-North Dakota-South Dakota"', add
label define statefip_lbl 70 `"Maine-Massachusetts-New Hampshire-Rhode Island-Vermont"', add
label define statefip_lbl 71 `"Michigan-Wisconsin"', add
label define statefip_lbl 72 `"Minnesota-Iowa"', add
label define statefip_lbl 73 `"Nebraska-North Dakota-South Dakota-Kansas"', add
label define statefip_lbl 74 `"Delaware-Virginia"', add
label define statefip_lbl 75 `"North Carolina-South Carolina"', add
label define statefip_lbl 76 `"Alabama-Mississippi"', add
label define statefip_lbl 77 `"Arkansas-Oklahoma"', add
label define statefip_lbl 78 `"Arizona-New Mexico-Colorado"', add
label define statefip_lbl 79 `"Idaho-Wyoming-Utah-Montana-Nevada"', add
label define statefip_lbl 80 `"Alaska-Washington-Hawaii"', add
label define statefip_lbl 81 `"New Hampshire-Maine-Vermont-Rhode Island"', add
label define statefip_lbl 83 `"South Carolina-Georgia"', add
label define statefip_lbl 84 `"Kentucky-Tennessee"', add
label define statefip_lbl 85 `"Arkansas-Louisiana-Oklahoma"', add
label define statefip_lbl 87 `"Iowa-N Dakota-S Dakota-Nebraska-Kansas-Minnesota-Missouri"', add
label define statefip_lbl 88 `"Washington-Oregon-Alaska-Hawaii"', add
label define statefip_lbl 89 `"Montana-Wyoming-Colorado-New Mexico-Utah-Nevada-Arizona"', add
label define statefip_lbl 90 `"Delaware-Maryland-Virginia-West Virginia"', add
label define statefip_lbl 99 `"State not identified"', add
label values statefip statefip_lbl

label define faminc_lbl 100 `"Under $5,000"'
label define faminc_lbl 110 `"Under $1,000"', add
label define faminc_lbl 111 `"Under $500"', add
label define faminc_lbl 112 `"$500 - 999"', add
label define faminc_lbl 120 `"$1,000 - 1,999"', add
label define faminc_lbl 121 `"$1,000 - 1,499"', add
label define faminc_lbl 122 `"$1,500-1,999"', add
label define faminc_lbl 130 `"$2,000 - 2,999"', add
label define faminc_lbl 131 `"$2,000 - 2,499"', add
label define faminc_lbl 132 `"$2,500 - 2,999"', add
label define faminc_lbl 140 `"$3,000 - 3,999"', add
label define faminc_lbl 141 `"$3,000 - 3,499"', add
label define faminc_lbl 142 `"$3,500 - 3,999"', add
label define faminc_lbl 150 `"$4,000 - 4,999"', add
label define faminc_lbl 200 `"$5,000 - 7,999"', add
label define faminc_lbl 210 `"$5,000 - 7,499"', add
label define faminc_lbl 220 `"$5,000 - 5,999"', add
label define faminc_lbl 230 `"$6,000 - 7,999"', add
label define faminc_lbl 231 `"$6,000 - 7,499"', add
label define faminc_lbl 232 `"$6,000 - 6,999"', add
label define faminc_lbl 233 `"$7,000 - 7,499"', add
label define faminc_lbl 234 `"$7,000 - 7,999"', add
label define faminc_lbl 300 `"$7,500 - 9,999"', add
label define faminc_lbl 310 `"$7,500 - 7,999"', add
label define faminc_lbl 320 `"$8,000 - 8,499"', add
label define faminc_lbl 330 `"$8,500 - 8,999"', add
label define faminc_lbl 340 `"$8,000 - 8,999"', add
label define faminc_lbl 350 `"$9,000 - 9,999"', add
label define faminc_lbl 400 `"$10,000 - 14,999"', add
label define faminc_lbl 410 `"$10,000 - 10,999"', add
label define faminc_lbl 420 `"$11,000 - 11,999"', add
label define faminc_lbl 430 `"$10,000 - 12,499"', add
label define faminc_lbl 440 `"$10,000 - 11,999"', add
label define faminc_lbl 450 `"$12,000 - 12,999"', add
label define faminc_lbl 460 `"$12,000 - 14,999"', add
label define faminc_lbl 470 `"$12,500 - 14,999"', add
label define faminc_lbl 480 `"$13,000 - 13,999"', add
label define faminc_lbl 490 `"$14,000 - 14,999"', add
label define faminc_lbl 500 `"$15,000 - 19,999"', add
label define faminc_lbl 510 `"$15,000 - 15,999"', add
label define faminc_lbl 520 `"$16,000 - 16,999"', add
label define faminc_lbl 530 `"$17,000 - 17,999"', add
label define faminc_lbl 540 `"$15,000 - 17,499"', add
label define faminc_lbl 550 `"$17,500 - 19,999"', add
label define faminc_lbl 560 `"$18,000 - 19,999"', add
label define faminc_lbl 600 `"$20,000 - 24,999"', add
label define faminc_lbl 700 `"$25,000 - 49,999"', add
label define faminc_lbl 710 `"$25,000 - 29,999"', add
label define faminc_lbl 720 `"$30,000 - 34,999"', add
label define faminc_lbl 730 `"$35,000 - 39,999"', add
label define faminc_lbl 740 `"$40,000 - 49,999"', add
label define faminc_lbl 800 `"$50,000 and over"', add
label define faminc_lbl 810 `"$50,000 - 74,999"', add
label define faminc_lbl 820 `"$50,000 - 59,999"', add
label define faminc_lbl 830 `"$60,000 - 74,999"', add
label define faminc_lbl 840 `"$75,000 and over"', add
label define faminc_lbl 841 `"$75,000 - 99,999"', add
label define faminc_lbl 842 `"$100,000 - 149,999"', add
label define faminc_lbl 843 `"$150,000 and over"', add
label define faminc_lbl 995 `"Missing"', add
label define faminc_lbl 996 `"Refused"', add
label define faminc_lbl 997 `"Don't know"', add
label define faminc_lbl 999 `"Blank"', add
label values faminc faminc_lbl

label define age_lbl 00 `"Under 1 year"'
label define age_lbl 01 `"1"', add
label define age_lbl 02 `"2"', add
label define age_lbl 03 `"3"', add
label define age_lbl 04 `"4"', add
label define age_lbl 05 `"5"', add
label define age_lbl 06 `"6"', add
label define age_lbl 07 `"7"', add
label define age_lbl 08 `"8"', add
label define age_lbl 09 `"9"', add
label define age_lbl 10 `"10"', add
label define age_lbl 11 `"11"', add
label define age_lbl 12 `"12"', add
label define age_lbl 13 `"13"', add
label define age_lbl 14 `"14"', add
label define age_lbl 15 `"15"', add
label define age_lbl 16 `"16"', add
label define age_lbl 17 `"17"', add
label define age_lbl 18 `"18"', add
label define age_lbl 19 `"19"', add
label define age_lbl 20 `"20"', add
label define age_lbl 21 `"21"', add
label define age_lbl 22 `"22"', add
label define age_lbl 23 `"23"', add
label define age_lbl 24 `"24"', add
label define age_lbl 25 `"25"', add
label define age_lbl 26 `"26"', add
label define age_lbl 27 `"27"', add
label define age_lbl 28 `"28"', add
label define age_lbl 29 `"29"', add
label define age_lbl 30 `"30"', add
label define age_lbl 31 `"31"', add
label define age_lbl 32 `"32"', add
label define age_lbl 33 `"33"', add
label define age_lbl 34 `"34"', add
label define age_lbl 35 `"35"', add
label define age_lbl 36 `"36"', add
label define age_lbl 37 `"37"', add
label define age_lbl 38 `"38"', add
label define age_lbl 39 `"39"', add
label define age_lbl 40 `"40"', add
label define age_lbl 41 `"41"', add
label define age_lbl 42 `"42"', add
label define age_lbl 43 `"43"', add
label define age_lbl 44 `"44"', add
label define age_lbl 45 `"45"', add
label define age_lbl 46 `"46"', add
label define age_lbl 47 `"47"', add
label define age_lbl 48 `"48"', add
label define age_lbl 49 `"49"', add
label define age_lbl 50 `"50"', add
label define age_lbl 51 `"51"', add
label define age_lbl 52 `"52"', add
label define age_lbl 53 `"53"', add
label define age_lbl 54 `"54"', add
label define age_lbl 55 `"55"', add
label define age_lbl 56 `"56"', add
label define age_lbl 57 `"57"', add
label define age_lbl 58 `"58"', add
label define age_lbl 59 `"59"', add
label define age_lbl 60 `"60"', add
label define age_lbl 61 `"61"', add
label define age_lbl 62 `"62"', add
label define age_lbl 63 `"63"', add
label define age_lbl 64 `"64"', add
label define age_lbl 65 `"65"', add
label define age_lbl 66 `"66"', add
label define age_lbl 67 `"67"', add
label define age_lbl 68 `"68"', add
label define age_lbl 69 `"69"', add
label define age_lbl 70 `"70"', add
label define age_lbl 71 `"71"', add
label define age_lbl 72 `"72"', add
label define age_lbl 73 `"73"', add
label define age_lbl 74 `"74"', add
label define age_lbl 75 `"75"', add
label define age_lbl 76 `"76"', add
label define age_lbl 77 `"77"', add
label define age_lbl 78 `"78"', add
label define age_lbl 79 `"79"', add
label define age_lbl 80 `"80"', add
label define age_lbl 81 `"81"', add
label define age_lbl 82 `"82"', add
label define age_lbl 83 `"83"', add
label define age_lbl 84 `"84"', add
label define age_lbl 85 `"85"', add
label define age_lbl 86 `"86"', add
label define age_lbl 87 `"87"', add
label define age_lbl 88 `"88"', add
label define age_lbl 89 `"89"', add
label define age_lbl 90 `"90 (90+, 1988-2002)"', add
label define age_lbl 91 `"91"', add
label define age_lbl 92 `"92"', add
label define age_lbl 93 `"93"', add
label define age_lbl 94 `"94"', add
label define age_lbl 95 `"95"', add
label define age_lbl 96 `"96"', add
label define age_lbl 97 `"97"', add
label define age_lbl 98 `"98"', add
label define age_lbl 99 `"99+"', add
label values age age_lbl

label define sex_lbl 1 `"Male"'
label define sex_lbl 2 `"Female"', add
label define sex_lbl 9 `"NIU"', add
label values sex sex_lbl

label define race_lbl 100 `"White"'
label define race_lbl 200 `"Black/Negro"', add
label define race_lbl 300 `"American Indian/Aleut/Eskimo"', add
label define race_lbl 650 `"Asian or Pacific Islander"', add
label define race_lbl 651 `"Asian only"', add
label define race_lbl 652 `"Hawaiian/Pacific Islander only"', add
label define race_lbl 700 `"Other (single) race, n.e.c."', add
label define race_lbl 801 `"White-Black"', add
label define race_lbl 802 `"White-American Indian"', add
label define race_lbl 803 `"White-Asian"', add
label define race_lbl 804 `"White-Hawaiian/Pacific Islander"', add
label define race_lbl 805 `"Black-American Indian"', add
label define race_lbl 806 `"Black-Asian"', add
label define race_lbl 807 `"Black-Hawaiian/Pacific Islander"', add
label define race_lbl 808 `"American Indian-Asian"', add
label define race_lbl 809 `"Asian-Hawaiian/Pacific Islander"', add
label define race_lbl 810 `"White-Black-American Indian"', add
label define race_lbl 811 `"White-Black-Asian"', add
label define race_lbl 812 `"White-American Indian-Asian"', add
label define race_lbl 813 `"White-Asian-Hawaiian/Pacific Islander"', add
label define race_lbl 814 `"White-Black-American Indian-Asian"', add
label define race_lbl 815 `"American Indian-Hawaiian/Pacific Islander"', add
label define race_lbl 816 `"White-Black--Hawaiian/Pacific Islander"', add
label define race_lbl 817 `"White-American Indian-Hawaiian/Pacific Islander"', add
label define race_lbl 818 `"Black-American Indian-Asian"', add
label define race_lbl 819 `"White-American Indian-Asian-Hawaiian/Pacific Islander"', add
label define race_lbl 820 `"Two or three races, unspecified"', add
label define race_lbl 830 `"Four or five races, unspecified"', add
label define race_lbl 999 `"Blank"', add
label values race race_lbl

label define ftype_lbl 1 `"Primary family"'
label define ftype_lbl 2 `"Nonfamily householder"', add
label define ftype_lbl 3 `"Related subfamily"', add
label define ftype_lbl 4 `"Unrelated subfamily"', add
label define ftype_lbl 5 `"Secondary individual"', add
label define ftype_lbl 9 `"Missing"', add
label values ftype ftype_lbl

label define famrel_lbl 0 `"Not a family member"'
label define famrel_lbl 1 `"Reference person"', add
label define famrel_lbl 2 `"Spouse"', add
label define famrel_lbl 3 `"Child"', add
label define famrel_lbl 4 `"Other relative (primary family only)"', add
label define famrel_lbl 9 `"Missing"', add
label values famrel famrel_lbl

label define hispan_lbl 000 `"Not Hispanic"'
label define hispan_lbl 100 `"Mexican"', add
label define hispan_lbl 102 `"Mexican American"', add
label define hispan_lbl 103 `"Mexicano/Mexicana"', add
label define hispan_lbl 104 `"Chicano/Chicana"', add
label define hispan_lbl 108 `"Mexican (Mexicano)"', add
label define hispan_lbl 109 `"Mexicano/Chicano"', add
label define hispan_lbl 200 `"Puerto Rican"', add
label define hispan_lbl 300 `"Cuban"', add
label define hispan_lbl 400 `"Dominican"', add
label define hispan_lbl 500 `"Salvadoran"', add
label define hispan_lbl 401 `"Other Hispanic"', add
label define hispan_lbl 410 `"Central/South American"', add
label define hispan_lbl 411 `"Central American, (excluding Salvadoran)"', add
label define hispan_lbl 412 `"South American"', add
label define hispan_lbl 901 `"Do not know"', add
label define hispan_lbl 902 `"N/A (and no response 1985-87)"', add
label values hispan hispan_lbl

label define educ_lbl 000 `"NIU or no schooling"'
label define educ_lbl 001 `"NIU or blank"', add
label define educ_lbl 002 `"None or preschool"', add
label define educ_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_lbl 011 `"Grade 1"', add
label define educ_lbl 012 `"Grade 2"', add
label define educ_lbl 013 `"Grade 3"', add
label define educ_lbl 014 `"Grade 4"', add
label define educ_lbl 020 `"Grades 5 or 6"', add
label define educ_lbl 021 `"Grade 5"', add
label define educ_lbl 022 `"Grade 6"', add
label define educ_lbl 030 `"Grades 7 or 8"', add
label define educ_lbl 031 `"Grade 7"', add
label define educ_lbl 032 `"Grade 8"', add
label define educ_lbl 040 `"Grade 9"', add
label define educ_lbl 050 `"Grade 10"', add
label define educ_lbl 060 `"Grade 11"', add
label define educ_lbl 070 `"Grade 12"', add
label define educ_lbl 071 `"12th grade, no diploma"', add
label define educ_lbl 072 `"12th grade, diploma unclear"', add
label define educ_lbl 073 `"High school diploma or equivalent"', add
label define educ_lbl 080 `"1 year of college"', add
label define educ_lbl 081 `"Some college but no degree"', add
label define educ_lbl 090 `"2 years of college"', add
label define educ_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_lbl 092 `"Associate's degree, academic program"', add
label define educ_lbl 100 `"3 years of college"', add
label define educ_lbl 110 `"4 years of college"', add
label define educ_lbl 111 `"Bachelor's degree"', add
label define educ_lbl 120 `"5+ years of college"', add
label define educ_lbl 121 `"5 years of college"', add
label define educ_lbl 122 `"6+ years of college"', add
label define educ_lbl 123 `"Master's degree"', add
label define educ_lbl 124 `"Professional school degree"', add
label define educ_lbl 125 `"Doctorate degree"', add
label define educ_lbl 999 `"Missing/Unknown"', add
label values educ educ_lbl

label define schlcoll_lbl 0 `"NIU"'
label define schlcoll_lbl 1 `"High school full time"', add
label define schlcoll_lbl 2 `"High school part time"', add
label define schlcoll_lbl 3 `"College or university full time"', add
label define schlcoll_lbl 4 `"College or university part time"', add
label define schlcoll_lbl 5 `"Does not attend school, college or university"', add
label values schlcoll schlcoll_lbl

label define tcig100_lbl 01 `"No"'
label define tcig100_lbl 02 `"Yes"', add
label define tcig100_lbl 96 `"Refused"', add
label define tcig100_lbl 97 `"Don't know"', add
label define tcig100_lbl 98 `"No Response"', add
label define tcig100_lbl 99 `"NIU"', add
label values tcig100 tcig100_lbl

label define tfreq_lbl 01 `"Not at all"'
label define tfreq_lbl 02 `"Some Days"', add
label define tfreq_lbl 03 `"Every Day"', add
label define tfreq_lbl 96 `"Refused"', add
label define tfreq_lbl 97 `"Don't know"', add
label define tfreq_lbl 98 `"No Response"', add
label define tfreq_lbl 99 `"NIU"', add
label values tfreq tfreq_lbl

label define educ_head_lbl 000 `"NIU or no schooling"'
label define educ_head_lbl 001 `"NIU or blank"', add
label define educ_head_lbl 002 `"None or preschool"', add
label define educ_head_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_head_lbl 011 `"Grade 1"', add
label define educ_head_lbl 012 `"Grade 2"', add
label define educ_head_lbl 013 `"Grade 3"', add
label define educ_head_lbl 014 `"Grade 4"', add
label define educ_head_lbl 020 `"Grades 5 or 6"', add
label define educ_head_lbl 021 `"Grade 5"', add
label define educ_head_lbl 022 `"Grade 6"', add
label define educ_head_lbl 030 `"Grades 7 or 8"', add
label define educ_head_lbl 031 `"Grade 7"', add
label define educ_head_lbl 032 `"Grade 8"', add
label define educ_head_lbl 040 `"Grade 9"', add
label define educ_head_lbl 050 `"Grade 10"', add
label define educ_head_lbl 060 `"Grade 11"', add
label define educ_head_lbl 070 `"Grade 12"', add
label define educ_head_lbl 071 `"12th grade, no diploma"', add
label define educ_head_lbl 072 `"12th grade, diploma unclear"', add
label define educ_head_lbl 073 `"High school diploma or equivalent"', add
label define educ_head_lbl 080 `"1 year of college"', add
label define educ_head_lbl 081 `"Some college but no degree"', add
label define educ_head_lbl 090 `"2 years of college"', add
label define educ_head_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_head_lbl 092 `"Associate's degree, academic program"', add
label define educ_head_lbl 100 `"3 years of college"', add
label define educ_head_lbl 110 `"4 years of college"', add
label define educ_head_lbl 111 `"Bachelor's degree"', add
label define educ_head_lbl 120 `"5+ years of college"', add
label define educ_head_lbl 121 `"5 years of college"', add
label define educ_head_lbl 122 `"6+ years of college"', add
label define educ_head_lbl 123 `"Master's degree"', add
label define educ_head_lbl 124 `"Professional school degree"', add
label define educ_head_lbl 125 `"Doctorate degree"', add
label define educ_head_lbl 999 `"Missing/Unknown"', add
label values educ_head educ_head_lbl

label define educ_mom_lbl 000 `"NIU or no schooling"'
label define educ_mom_lbl 001 `"NIU or blank"', add
label define educ_mom_lbl 002 `"None or preschool"', add
label define educ_mom_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_mom_lbl 011 `"Grade 1"', add
label define educ_mom_lbl 012 `"Grade 2"', add
label define educ_mom_lbl 013 `"Grade 3"', add
label define educ_mom_lbl 014 `"Grade 4"', add
label define educ_mom_lbl 020 `"Grades 5 or 6"', add
label define educ_mom_lbl 021 `"Grade 5"', add
label define educ_mom_lbl 022 `"Grade 6"', add
label define educ_mom_lbl 030 `"Grades 7 or 8"', add
label define educ_mom_lbl 031 `"Grade 7"', add
label define educ_mom_lbl 032 `"Grade 8"', add
label define educ_mom_lbl 040 `"Grade 9"', add
label define educ_mom_lbl 050 `"Grade 10"', add
label define educ_mom_lbl 060 `"Grade 11"', add
label define educ_mom_lbl 070 `"Grade 12"', add
label define educ_mom_lbl 071 `"12th grade, no diploma"', add
label define educ_mom_lbl 072 `"12th grade, diploma unclear"', add
label define educ_mom_lbl 073 `"High school diploma or equivalent"', add
label define educ_mom_lbl 080 `"1 year of college"', add
label define educ_mom_lbl 081 `"Some college but no degree"', add
label define educ_mom_lbl 090 `"2 years of college"', add
label define educ_mom_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_mom_lbl 092 `"Associate's degree, academic program"', add
label define educ_mom_lbl 100 `"3 years of college"', add
label define educ_mom_lbl 110 `"4 years of college"', add
label define educ_mom_lbl 111 `"Bachelor's degree"', add
label define educ_mom_lbl 120 `"5+ years of college"', add
label define educ_mom_lbl 121 `"5 years of college"', add
label define educ_mom_lbl 122 `"6+ years of college"', add
label define educ_mom_lbl 123 `"Master's degree"', add
label define educ_mom_lbl 124 `"Professional school degree"', add
label define educ_mom_lbl 125 `"Doctorate degree"', add
label define educ_mom_lbl 999 `"Missing/Unknown"', add
label values educ_mom educ_mom_lbl

label define educ_mom2_lbl 000 `"NIU or no schooling"'
label define educ_mom2_lbl 001 `"NIU or blank"', add
label define educ_mom2_lbl 002 `"None or preschool"', add
label define educ_mom2_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_mom2_lbl 011 `"Grade 1"', add
label define educ_mom2_lbl 012 `"Grade 2"', add
label define educ_mom2_lbl 013 `"Grade 3"', add
label define educ_mom2_lbl 014 `"Grade 4"', add
label define educ_mom2_lbl 020 `"Grades 5 or 6"', add
label define educ_mom2_lbl 021 `"Grade 5"', add
label define educ_mom2_lbl 022 `"Grade 6"', add
label define educ_mom2_lbl 030 `"Grades 7 or 8"', add
label define educ_mom2_lbl 031 `"Grade 7"', add
label define educ_mom2_lbl 032 `"Grade 8"', add
label define educ_mom2_lbl 040 `"Grade 9"', add
label define educ_mom2_lbl 050 `"Grade 10"', add
label define educ_mom2_lbl 060 `"Grade 11"', add
label define educ_mom2_lbl 070 `"Grade 12"', add
label define educ_mom2_lbl 071 `"12th grade, no diploma"', add
label define educ_mom2_lbl 072 `"12th grade, diploma unclear"', add
label define educ_mom2_lbl 073 `"High school diploma or equivalent"', add
label define educ_mom2_lbl 080 `"1 year of college"', add
label define educ_mom2_lbl 081 `"Some college but no degree"', add
label define educ_mom2_lbl 090 `"2 years of college"', add
label define educ_mom2_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_mom2_lbl 092 `"Associate's degree, academic program"', add
label define educ_mom2_lbl 100 `"3 years of college"', add
label define educ_mom2_lbl 110 `"4 years of college"', add
label define educ_mom2_lbl 111 `"Bachelor's degree"', add
label define educ_mom2_lbl 120 `"5+ years of college"', add
label define educ_mom2_lbl 121 `"5 years of college"', add
label define educ_mom2_lbl 122 `"6+ years of college"', add
label define educ_mom2_lbl 123 `"Master's degree"', add
label define educ_mom2_lbl 124 `"Professional school degree"', add
label define educ_mom2_lbl 125 `"Doctorate degree"', add
label define educ_mom2_lbl 999 `"Missing/Unknown"', add
label values educ_mom2 educ_mom2_lbl

label define educ_pop_lbl 000 `"NIU or no schooling"'
label define educ_pop_lbl 001 `"NIU or blank"', add
label define educ_pop_lbl 002 `"None or preschool"', add
label define educ_pop_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_pop_lbl 011 `"Grade 1"', add
label define educ_pop_lbl 012 `"Grade 2"', add
label define educ_pop_lbl 013 `"Grade 3"', add
label define educ_pop_lbl 014 `"Grade 4"', add
label define educ_pop_lbl 020 `"Grades 5 or 6"', add
label define educ_pop_lbl 021 `"Grade 5"', add
label define educ_pop_lbl 022 `"Grade 6"', add
label define educ_pop_lbl 030 `"Grades 7 or 8"', add
label define educ_pop_lbl 031 `"Grade 7"', add
label define educ_pop_lbl 032 `"Grade 8"', add
label define educ_pop_lbl 040 `"Grade 9"', add
label define educ_pop_lbl 050 `"Grade 10"', add
label define educ_pop_lbl 060 `"Grade 11"', add
label define educ_pop_lbl 070 `"Grade 12"', add
label define educ_pop_lbl 071 `"12th grade, no diploma"', add
label define educ_pop_lbl 072 `"12th grade, diploma unclear"', add
label define educ_pop_lbl 073 `"High school diploma or equivalent"', add
label define educ_pop_lbl 080 `"1 year of college"', add
label define educ_pop_lbl 081 `"Some college but no degree"', add
label define educ_pop_lbl 090 `"2 years of college"', add
label define educ_pop_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_pop_lbl 092 `"Associate's degree, academic program"', add
label define educ_pop_lbl 100 `"3 years of college"', add
label define educ_pop_lbl 110 `"4 years of college"', add
label define educ_pop_lbl 111 `"Bachelor's degree"', add
label define educ_pop_lbl 120 `"5+ years of college"', add
label define educ_pop_lbl 121 `"5 years of college"', add
label define educ_pop_lbl 122 `"6+ years of college"', add
label define educ_pop_lbl 123 `"Master's degree"', add
label define educ_pop_lbl 124 `"Professional school degree"', add
label define educ_pop_lbl 125 `"Doctorate degree"', add
label define educ_pop_lbl 999 `"Missing/Unknown"', add
label values educ_pop educ_pop_lbl

label define educ_pop2_lbl 000 `"NIU or no schooling"'
label define educ_pop2_lbl 001 `"NIU or blank"', add
label define educ_pop2_lbl 002 `"None or preschool"', add
label define educ_pop2_lbl 010 `"Grades 1, 2, 3, or 4"', add
label define educ_pop2_lbl 011 `"Grade 1"', add
label define educ_pop2_lbl 012 `"Grade 2"', add
label define educ_pop2_lbl 013 `"Grade 3"', add
label define educ_pop2_lbl 014 `"Grade 4"', add
label define educ_pop2_lbl 020 `"Grades 5 or 6"', add
label define educ_pop2_lbl 021 `"Grade 5"', add
label define educ_pop2_lbl 022 `"Grade 6"', add
label define educ_pop2_lbl 030 `"Grades 7 or 8"', add
label define educ_pop2_lbl 031 `"Grade 7"', add
label define educ_pop2_lbl 032 `"Grade 8"', add
label define educ_pop2_lbl 040 `"Grade 9"', add
label define educ_pop2_lbl 050 `"Grade 10"', add
label define educ_pop2_lbl 060 `"Grade 11"', add
label define educ_pop2_lbl 070 `"Grade 12"', add
label define educ_pop2_lbl 071 `"12th grade, no diploma"', add
label define educ_pop2_lbl 072 `"12th grade, diploma unclear"', add
label define educ_pop2_lbl 073 `"High school diploma or equivalent"', add
label define educ_pop2_lbl 080 `"1 year of college"', add
label define educ_pop2_lbl 081 `"Some college but no degree"', add
label define educ_pop2_lbl 090 `"2 years of college"', add
label define educ_pop2_lbl 091 `"Associate's degree, occupational/vocational program"', add
label define educ_pop2_lbl 092 `"Associate's degree, academic program"', add
label define educ_pop2_lbl 100 `"3 years of college"', add
label define educ_pop2_lbl 110 `"4 years of college"', add
label define educ_pop2_lbl 111 `"Bachelor's degree"', add
label define educ_pop2_lbl 120 `"5+ years of college"', add
label define educ_pop2_lbl 121 `"5 years of college"', add
label define educ_pop2_lbl 122 `"6+ years of college"', add
label define educ_pop2_lbl 123 `"Master's degree"', add
label define educ_pop2_lbl 124 `"Professional school degree"', add
label define educ_pop2_lbl 125 `"Doctorate degree"', add
label define educ_pop2_lbl 999 `"Missing/Unknown"', add
label values educ_pop2 educ_pop2_lbl


*********************************
**PART 2 - CLEAN, MERGE
*********************************

*take out those who are not in the universe (small fraction of sample)
drop if tcig100==99

*gen smoking vars
gen smk100 = tcig100
recode smk100 (2=1) (1=0) (96/97 = 1) (98= .)
gen curr_smoke = tfreq
recode curr_smoke (2/3 = 1) (1= 0) (99 = 0) (96/97 = .) (98 = .)

gen ever_smoke = smk100

*generate race variables (groups match YRBS exactly)

gen race_min = .
recode race_min (.=1) if race==100&hispan==0
recode race_min (.=2) if race==200|race==300|race==801|race==802|(race>=805&race<=807)|race==809|(hispan>0&hispan<901)

gen race_grp = .
replace race_grp = 1 if race_min==1
replace race_grp = 2 if race==200
replace race_grp = 4 if race==300
replace race_grp = 5 if race>=650&race<=652
replace race_grp = 3 if (hispan>0&hispan<901)
replace race_grp = 6 if race_grp==.

label define race6l 1"white" 2"black" 3"Hispanic" 4"asian" 5"native american" 6"other"
label values race_grp race6l

*generate education variables

mark hs if educ>=73
mark some_coll if educ>73
mark coll if educ>=111
mark post_grad if educ>=123

*merge in state policy info
*in two separate stata files
joinby stfips year using "$data/state_policies.dta", unmatched(master) _merge(_POL)
rename cigtax cigtax2
gen cigtax=cigtax2/100
drop cigtax2

joinby stfip year using "$data/gdp_pop.dta", unmatched(master) _merge(_ECON)
gen ln_beertax = ln(beertaxrate)
gen ln_cigtax = ln(cigtax)
gen ln_real_pci = ln(real_pci)
gen ln_pop = ln(pop)

save "$data/TUSCPS_datafile.dta", replace
